const express = require('express');
const router = express.Router();
const fileController = require('../../controllers/common/file.controller');
const auth = require('../../middlewares/auth');
const validate = require('../../middlewares/validate');
const fileValidation = require('../../validations/file.validation');

// 下载文件（通用接口）
router.get(
  '/download/:fileId',
  auth(), // 所有认证用户均可访问
  validate(fileValidation.downloadFile),
  fileController.downloadFile
);

// 教师下载成绩报表（Excel）
router.get(
  '/reports/class-grades/:classId',
  auth(['teacher', 'admin']), // 教师和管理员可访问
  validate(fileValidation.downloadGradeReport),
  fileController.downloadGradeReport
);

module.exports = router;